// pages/yuncun/yuncun.js
import request from '../../utils/request'
Page({
  data: {
    mvlist: [],
    newsonglist:[],
    toplist:[]
  },
  go_mv(e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/play_mv/play_mv?id=' + id,
    })
  },
  go_newsong(e){
    wx.navigateTo({
      url: '/pages/newsong/newsong?id='+e.currentTarget.dataset.id,
    })
  },
  go_songdetail(e){
    let musicId = e.currentTarget.dataset.id
    let title = e.currentTarget.dataset.title
    wx.navigateTo({
      url: `/pages/songDetail/songDetail?musicId=${musicId}&source=${title}`,
    })
  },
  go_songerlist(){
    wx.navigateTo({
      url: '/pages/songerlist/songerlist',
    })
  },

  go_songsheet(){
    wx.navigateTo({
      url: '/pages/songsheet/songsheet',
    })
  },

  go_sheetlist(e){
    wx.navigateTo({
      url: '/pages/songsheet/songsheetlist?id='+e.currentTarget.dataset.id,
    })
  },

  go_search(e){
    wx.navigateTo({
      url: '/pages/search/search',
    })
  },



  async mvlist(){
    let mvlist = await request('/top/mv',{limit:4});
    this.setData({
      mvlist:mvlist.data
    })
  },

  async toplist(){
    let toplist = await request('/top/playlist',{limit:12});
    this.setData({
      toplist:toplist.playlists
    })
  },

  async getnewsong(){
    let newsonglist = await request('/personalized/newsong',{limit:12})
    this.setData({
      newsonglist:newsonglist.result
    })
  },
  onLoad(options) {
    this.mvlist()
    this.getnewsong()
    this.toplist()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})